class TagBuilder(object):
	CLOSABLE = 1
	ONELINE = 2
	
	Opening = ('<', '>')
	Ending = ('</', '>')
	OnelineFormat = ('<', '/>')
	
	def rebuild_tag(name, attrs, ttype=1):
		"""Rebuilds the opening string for this tag"""
		tag_str = TagBuilder.Opening[0]+name
		
		for key,value in attrs.iteritems():
			tag_str+=' '+key+'="'+value+'"'
			
		if ttype == TagBuilder.CLOSABLE:
			tag_str += TagBuilder.Opening[1]
		else:
			tag_str += TagBuilder.OnelineFormat[1]
		return tag_str
	rebuild_tag = staticmethod(rebuild_tag)
		
	def rebuild_closure(name, ttype=1):
		"""Creates the string which closes this tag"""
		if ttype == TagBuilder.CLOSABLE:
			return TagBuilder.Ending[0]+name+TagBuilder.Ending[1]
		else:
			return ''
	rebuild_closure = staticmethod(rebuild_closure)